package edu.sctu.renpingan.seekhomework;

import java.io.File;
import java.io.IOException;

/**
 * Created by Administrator on 2015/6/30.
 */

/**
 * 对文件夹的处理类
 */

public class JudgeIsFile {
    String savePath;
    String addFilePath;
    public JudgeIsFile(String savePath,String addFilePath){
        this.savePath = savePath;
        this.addFilePath = addFilePath;

    }
    public void JudgeAndCreatSaveFile() throws IOException {//判断存放完整信息的文件夹是否存在，没有时创建
        File file=new File(savePath);
        if (!file.exists()) {
            file.mkdirs();
        }
    }
    public void JudgeAndCreatNewFile() throws IOException {//判断存放新添信息的文件夹是否存在，没有时创建
        File file=new File(addFilePath);
        if (!file.exists()) {
            file.mkdirs();
        }
    }
    public boolean judgeSaveFileIsEmpty(){//判断存放完整信息的文件夹是否为空
        File file = new File(savePath );
        String[] filename;
        filename = file.list();
        if(filename.length == 0){
            return true;
        }else{
            return false;
        }

    }
    public boolean judgeAndAddFileIsEmpty() throws IOException {//判断存放新添信息的文件夹是否为空
        File file = new File(addFilePath);
        String[] filename;
        filename = file.list();
        if(filename.length == 0){
            return true;
        }else{
            return false;
        }
    }


}
